<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class ArticleCategory.
 *
 * @package namespace App\Repository\Models;
 */
class ArticleCategory extends Model implements Transformable
{
    use TransformableTrait;
    use SoftDeletes;

    protected $table = 'article_category';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id','fid','type_id','title','created_at','sort','is_show'];
    // protected $hidden   = ['id'];
    protected $appends  = ['cate_id','fid_name'];

    public function getCateIdAttribute(){
        return $this->id;
    }
    public function getFidNameAttribute(){
        $name = ArticleCategory::query()->where('id',$this->fid)->first();
        return isset($name['title'])?$name['title']:'-';
    }
}
